//__dirname是node.js中的一个全局变量，它指向当前执行脚本所在的目录
var path = require("path");
var webpack = require('webpack');
var babelpolyfill = require("babel-polyfill");
module.exports = {//注意这里是exports不是export
    devtool: 'eval-source-map',
    entry: ['webpack/hot/dev-server', __dirname + '/app/main.js'],
    output: {//输出目录
        path: __dirname + "/build",//打包后的js文件存放的地方
        filename: "bundle.js"//打包后的js文件名
    },
    module: {
        //loaders加载器
        loaders: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                loader: 'babel-loader'                
            },
            {
                test: /\.scss$/,
                loaders: ["style", "css?sourceMap", "sass?sourceMap"]
            },
            {
                test: /\.less$/,
                use: [{
                     loader: "style-loader" // creates style nodes from JS strings
                 }, {
                     loader: "css-loader" // translates CSS into CommonJS
                 }, {
                     loader: "less-loader" // compiles Less to CSS
                 }]
            },
            {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            },
            {                
        　　　　　test: /\.(png|jpg)$/,
        　　　　　loader: 'url-loader?limit=8192&name=img/[hash:8].[name].[ext]'　　　　
    　　　　 }            
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),//热模块替换插件
        new webpack.ProvidePlugin({            
            $:"jquery",            
            jQuery:"jquery",            
            "window.jQuery":"jquery"            
        })
    ],
    devServer: {
        contentBase: './build',        
        historyApiFallback: true,
        inline: true,
        port: 8080,        
    }
};
